package com.innovations.inn.service.impl;

import java.util.List;
import com.innovations.common.utils.DateUtils;
import com.innovations.common.utils.uuid.IdGeneratorSnowflake;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.innovations.inn.mapper.BusinessDemandFilesMapper;
import com.innovations.inn.domain.BusinessDemandFiles;
import com.innovations.inn.service.IBusinessDemandFilesService;

/**
 * 商业需求附件Service业务层处理
 * 
 * @author dp
 * @date 2024-08-09
 */
@Service
public class BusinessDemandFilesServiceImpl implements IBusinessDemandFilesService 
{
    @Autowired
    private BusinessDemandFilesMapper businessDemandFilesMapper;
    @Autowired
    IdGeneratorSnowflake idGeneratorSnowflake;

    /**
     * 查询商业需求附件
     * 
     * @param businessDemandFilesId 商业需求附件主键
     * @return 商业需求附件
     */
    @Override
    public BusinessDemandFiles selectBusinessDemandFilesByBusinessDemandFilesId(Long businessDemandFilesId)
    {
        return businessDemandFilesMapper.selectBusinessDemandFilesByBusinessDemandFilesId(businessDemandFilesId);
    }

    /**
     * 查询商业需求附件列表
     * 
     * @param businessDemandFiles 商业需求附件
     * @return 商业需求附件
     */
    @Override
    public List<BusinessDemandFiles> selectBusinessDemandFilesList(BusinessDemandFiles businessDemandFiles)
    {
        return businessDemandFilesMapper.selectBusinessDemandFilesList(businessDemandFiles);
    }

    /**
     * 新增商业需求附件
     * 
     * @param businessDemandFiles 商业需求附件
     * @return 结果
     */
    @Override
    public int insertBusinessDemandFiles(BusinessDemandFiles businessDemandFiles)
    {
        businessDemandFiles.setCreateTime(DateUtils.getNowDate());
        return businessDemandFilesMapper.insertBusinessDemandFiles(businessDemandFiles);
    }

    /**
     * 修改商业需求附件
     * 
     * @param businessDemandFiles 商业需求附件
     * @return 结果
     */
    @Override
    public int updateBusinessDemandFiles(BusinessDemandFiles businessDemandFiles)
    {
        return businessDemandFilesMapper.updateBusinessDemandFiles(businessDemandFiles);
    }

    /**
     * 批量删除商业需求附件
     * 
     * @param businessDemandFilesIds 需要删除的商业需求附件主键
     * @return 结果
     */
    @Override
    public int deleteBusinessDemandFilesByBusinessDemandFilesIds(Long[] businessDemandFilesIds)
    {
        return businessDemandFilesMapper.deleteBusinessDemandFilesByBusinessDemandFilesIds(businessDemandFilesIds);
    }

    /**
     * 删除商业需求附件信息
     * 
     * @param businessDemandFilesId 商业需求附件主键
     * @return 结果
     */
    @Override
    public int deleteBusinessDemandFilesByBusinessDemandFilesId(Long businessDemandFilesId)
    {
        return businessDemandFilesMapper.deleteBusinessDemandFilesByBusinessDemandFilesId(businessDemandFilesId);
    }

    /**
     * 实体数据补全
     *
     * @param businessDemandFiles 实体
     * @param userId       用户id
     * @param crateType    创建类型 1：新增 2：修改
     */
    @Override
    public void completeData(BusinessDemandFiles businessDemandFiles, Long userId, Integer crateType) {
        //主键
        if (businessDemandFiles.getBusinessDemandFilesId() == null || "".equals(businessDemandFiles.getBusinessDemandFilesId())) {
            businessDemandFiles.setBusinessDemandFilesId(idGeneratorSnowflake.nextId());
        }
        //创建人、创建时间
        if (crateType == 1) {
            if (businessDemandFiles.getCreateBy() == null || "".equals(businessDemandFiles.getCreateBy())) {
                businessDemandFiles.setCreateBy(userId);
            }
            if (businessDemandFiles.getCreateTime() == null) {
                businessDemandFiles.setCreateTime(DateUtils.getNowDate());
            }
        }
//        //修改人
//        if (businessDemandFiles.getModifyBy() == null) {
//            businessDemandFiles.setModifyBy(userId);
//        }
//        //修改时间
//        if (businessDemandFiles.getModifyTime() == null) {
//            businessDemandFiles.setModifyTime(DateUtils.getNowDate());
//        }
    }
}
